# random
import random

ran = random.random()  # 0-1之间的随机数
print(ran)  # 0.18367496163890407

rd = random.randrange(1, 10, 2)

print(rd)

ri = random.randint(1, 10)

print(ri)

lst = ['lucy', 'zhang_san', 'san_duo', 'lisi']

ran = random.choice(lst)  # 随机选择列表中的值
print(ran)

random.shuffle(lst)  # 洗牌：['zhang_san', 'lucy', 'san_duo', 'lisi']
print(lst)


# 验证码。大写字母与数字的组合

def func():
    code = ''
    for i in range(4):
        ran1 = str(random.randint(0, 9))
        ran2 = chr(random.randint(65, 90))
        ran3 = chr(random.randint(97, 132))
        r = random.choice([ran1, ran2, ran3])
        code += r
    return code


print(func())
print(func())
